<?php

namespace GotchaDatabase\om;

use \Criteria;
use \Exception;
use \ModelCriteria;
use \PDO;
use \Propel;
use \PropelException;
use \PropelObjectCollection;
use \PropelPDO;
use GotchaDatabase\JasminumCalendarReservations;
use GotchaDatabase\JasminumCalendarReservationsPeer;
use GotchaDatabase\JasminumCalendarReservationsQuery;

/**
 * Base class that represents a query for the 'Jasminum_Calendar_Reservations' table.
 *
 *
 *
 * @method JasminumCalendarReservationsQuery orderById($order = Criteria::ASC) Order by the Id column
 * @method JasminumCalendarReservationsQuery orderByFirstname($order = Criteria::ASC) Order by the Firstname column
 * @method JasminumCalendarReservationsQuery orderByLastname($order = Criteria::ASC) Order by the Lastname column
 * @method JasminumCalendarReservationsQuery orderByEmail($order = Criteria::ASC) Order by the Email column
 * @method JasminumCalendarReservationsQuery orderByDateFrom($order = Criteria::ASC) Order by the Date_From column
 * @method JasminumCalendarReservationsQuery orderByDateTo($order = Criteria::ASC) Order by the Date_To column
 * @method JasminumCalendarReservationsQuery orderByPhone($order = Criteria::ASC) Order by the Phone column
 * @method JasminumCalendarReservationsQuery orderByHall($order = Criteria::ASC) Order by the Hall column
 *
 * @method JasminumCalendarReservationsQuery groupById() Group by the Id column
 * @method JasminumCalendarReservationsQuery groupByFirstname() Group by the Firstname column
 * @method JasminumCalendarReservationsQuery groupByLastname() Group by the Lastname column
 * @method JasminumCalendarReservationsQuery groupByEmail() Group by the Email column
 * @method JasminumCalendarReservationsQuery groupByDateFrom() Group by the Date_From column
 * @method JasminumCalendarReservationsQuery groupByDateTo() Group by the Date_To column
 * @method JasminumCalendarReservationsQuery groupByPhone() Group by the Phone column
 * @method JasminumCalendarReservationsQuery groupByHall() Group by the Hall column
 *
 * @method JasminumCalendarReservationsQuery leftJoin($relation) Adds a LEFT JOIN clause to the query
 * @method JasminumCalendarReservationsQuery rightJoin($relation) Adds a RIGHT JOIN clause to the query
 * @method JasminumCalendarReservationsQuery innerJoin($relation) Adds a INNER JOIN clause to the query
 *
 * @method JasminumCalendarReservations findOne(PropelPDO $con = null) Return the first JasminumCalendarReservations matching the query
 * @method JasminumCalendarReservations findOneOrCreate(PropelPDO $con = null) Return the first JasminumCalendarReservations matching the query, or a new JasminumCalendarReservations object populated from the query conditions when no match is found
 *
 * @method JasminumCalendarReservations findOneByFirstname(string $Firstname) Return the first JasminumCalendarReservations filtered by the Firstname column
 * @method JasminumCalendarReservations findOneByLastname(string $Lastname) Return the first JasminumCalendarReservations filtered by the Lastname column
 * @method JasminumCalendarReservations findOneByEmail(string $Email) Return the first JasminumCalendarReservations filtered by the Email column
 * @method JasminumCalendarReservations findOneByDateFrom(string $Date_From) Return the first JasminumCalendarReservations filtered by the Date_From column
 * @method JasminumCalendarReservations findOneByDateTo(string $Date_To) Return the first JasminumCalendarReservations filtered by the Date_To column
 * @method JasminumCalendarReservations findOneByPhone(string $Phone) Return the first JasminumCalendarReservations filtered by the Phone column
 * @method JasminumCalendarReservations findOneByHall(int $Hall) Return the first JasminumCalendarReservations filtered by the Hall column
 *
 * @method array findById(int $Id) Return JasminumCalendarReservations objects filtered by the Id column
 * @method array findByFirstname(string $Firstname) Return JasminumCalendarReservations objects filtered by the Firstname column
 * @method array findByLastname(string $Lastname) Return JasminumCalendarReservations objects filtered by the Lastname column
 * @method array findByEmail(string $Email) Return JasminumCalendarReservations objects filtered by the Email column
 * @method array findByDateFrom(string $Date_From) Return JasminumCalendarReservations objects filtered by the Date_From column
 * @method array findByDateTo(string $Date_To) Return JasminumCalendarReservations objects filtered by the Date_To column
 * @method array findByPhone(string $Phone) Return JasminumCalendarReservations objects filtered by the Phone column
 * @method array findByHall(int $Hall) Return JasminumCalendarReservations objects filtered by the Hall column
 *
 * @package    propel.generator.gotcha.om
 */
abstract class BaseJasminumCalendarReservationsQuery extends ModelCriteria
{
    /**
     * Initializes internal state of BaseJasminumCalendarReservationsQuery object.
     *
     * @param     string $dbName The dabase name
     * @param     string $modelName The phpName of a model, e.g. 'Book'
     * @param     string $modelAlias The alias for the model in this query, e.g. 'b'
     */
    public function __construct($dbName = 'codenova_jasminum', $modelName = 'GotchaDatabase\\JasminumCalendarReservations', $modelAlias = null)
    {
        parent::__construct($dbName, $modelName, $modelAlias);
    }

    /**
     * Returns a new JasminumCalendarReservationsQuery object.
     *
     * @param     string $modelAlias The alias of a model in the query
     * @param   JasminumCalendarReservationsQuery|Criteria $criteria Optional Criteria to build the query from
     *
     * @return JasminumCalendarReservationsQuery
     */
    public static function create($modelAlias = null, $criteria = null)
    {
        if ($criteria instanceof JasminumCalendarReservationsQuery) {
            return $criteria;
        }
        $query = new JasminumCalendarReservationsQuery();
        if (null !== $modelAlias) {
            $query->setModelAlias($modelAlias);
        }
        if ($criteria instanceof Criteria) {
            $query->mergeWith($criteria);
        }

        return $query;
    }

    /**
     * Find object by primary key.
     * Propel uses the instance pool to skip the database if the object exists.
     * Go fast if the query is untouched.
     *
     * <code>
     * $obj  = $c->findPk(12, $con);
     * </code>
     *
     * @param mixed $key Primary key to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return   JasminumCalendarReservations|JasminumCalendarReservations[]|mixed the result, formatted by the current formatter
     */
    public function findPk($key, $con = null)
    {
        if ($key === null) {
            return null;
        }
        if ((null !== ($obj = JasminumCalendarReservationsPeer::getInstanceFromPool((string) $key))) && !$this->formatter) {
            // the object is already in the instance pool
            return $obj;
        }
        if ($con === null) {
            $con = Propel::getConnection(JasminumCalendarReservationsPeer::DATABASE_NAME, Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        if ($this->formatter || $this->modelAlias || $this->with || $this->select
         || $this->selectColumns || $this->asColumns || $this->selectModifiers
         || $this->map || $this->having || $this->joins) {
            return $this->findPkComplex($key, $con);
        } else {
            return $this->findPkSimple($key, $con);
        }
    }

    /**
     * Alias of findPk to use instance pooling
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return                 JasminumCalendarReservations A model object, or null if the key is not found
     * @throws PropelException
     */
     public function findOneById($key, $con = null)
     {
        return $this->findPk($key, $con);
     }

    /**
     * Find object by primary key using raw SQL to go fast.
     * Bypass doSelect() and the object formatter by using generated code.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return                 JasminumCalendarReservations A model object, or null if the key is not found
     * @throws PropelException
     */
    protected function findPkSimple($key, $con)
    {
        $sql = 'SELECT `Id`, `Firstname`, `Lastname`, `Email`, `Date_From`, `Date_To`, `Phone`, `Hall` FROM `Jasminum_Calendar_Reservations` WHERE `Id` = :p0';
        try {
            $stmt = $con->prepare($sql);
            $stmt->bindValue(':p0', $key, PDO::PARAM_INT);
            $stmt->execute();
        } catch (Exception $e) {
            Propel::log($e->getMessage(), Propel::LOG_ERR);
            throw new PropelException(sprintf('Unable to execute SELECT statement [%s]', $sql), $e);
        }
        $obj = null;
        if ($row = $stmt->fetch(PDO::FETCH_NUM)) {
            $obj = new JasminumCalendarReservations();
            $obj->hydrate($row);
            JasminumCalendarReservationsPeer::addInstanceToPool($obj, (string) $key);
        }
        $stmt->closeCursor();

        return $obj;
    }

    /**
     * Find object by primary key.
     *
     * @param     mixed $key Primary key to use for the query
     * @param     PropelPDO $con A connection object
     *
     * @return JasminumCalendarReservations|JasminumCalendarReservations[]|mixed the result, formatted by the current formatter
     */
    protected function findPkComplex($key, $con)
    {
        // As the query uses a PK condition, no limit(1) is necessary.
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKey($key)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->formatOne($stmt);
    }

    /**
     * Find objects by primary key
     * <code>
     * $objs = $c->findPks(array(12, 56, 832), $con);
     * </code>
     * @param     array $keys Primary keys to use for the query
     * @param     PropelPDO $con an optional connection object
     *
     * @return PropelObjectCollection|JasminumCalendarReservations[]|mixed the list of results, formatted by the current formatter
     */
    public function findPks($keys, $con = null)
    {
        if ($con === null) {
            $con = Propel::getConnection($this->getDbName(), Propel::CONNECTION_READ);
        }
        $this->basePreSelect($con);
        $criteria = $this->isKeepQuery() ? clone $this : $this;
        $stmt = $criteria
            ->filterByPrimaryKeys($keys)
            ->doSelect($con);

        return $criteria->getFormatter()->init($criteria)->format($stmt);
    }

    /**
     * Filter the query by primary key
     *
     * @param     mixed $key Primary key to use for the query
     *
     * @return JasminumCalendarReservationsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKey($key)
    {

        return $this->addUsingAlias(JasminumCalendarReservationsPeer::ID, $key, Criteria::EQUAL);
    }

    /**
     * Filter the query by a list of primary keys
     *
     * @param     array $keys The list of primary key to use for the query
     *
     * @return JasminumCalendarReservationsQuery The current query, for fluid interface
     */
    public function filterByPrimaryKeys($keys)
    {

        return $this->addUsingAlias(JasminumCalendarReservationsPeer::ID, $keys, Criteria::IN);
    }

    /**
     * Filter the query on the Id column
     *
     * Example usage:
     * <code>
     * $query->filterById(1234); // WHERE Id = 1234
     * $query->filterById(array(12, 34)); // WHERE Id IN (12, 34)
     * $query->filterById(array('min' => 12)); // WHERE Id >= 12
     * $query->filterById(array('max' => 12)); // WHERE Id <= 12
     * </code>
     *
     * @param     mixed $id The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return JasminumCalendarReservationsQuery The current query, for fluid interface
     */
    public function filterById($id = null, $comparison = null)
    {
        if (is_array($id)) {
            $useMinMax = false;
            if (isset($id['min'])) {
                $this->addUsingAlias(JasminumCalendarReservationsPeer::ID, $id['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($id['max'])) {
                $this->addUsingAlias(JasminumCalendarReservationsPeer::ID, $id['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(JasminumCalendarReservationsPeer::ID, $id, $comparison);
    }

    /**
     * Filter the query on the Firstname column
     *
     * Example usage:
     * <code>
     * $query->filterByFirstname('fooValue');   // WHERE Firstname = 'fooValue'
     * $query->filterByFirstname('%fooValue%'); // WHERE Firstname LIKE '%fooValue%'
     * </code>
     *
     * @param     string $firstname The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return JasminumCalendarReservationsQuery The current query, for fluid interface
     */
    public function filterByFirstname($firstname = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($firstname)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $firstname)) {
                $firstname = str_replace('*', '%', $firstname);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(JasminumCalendarReservationsPeer::FIRSTNAME, $firstname, $comparison);
    }

    /**
     * Filter the query on the Lastname column
     *
     * Example usage:
     * <code>
     * $query->filterByLastname('fooValue');   // WHERE Lastname = 'fooValue'
     * $query->filterByLastname('%fooValue%'); // WHERE Lastname LIKE '%fooValue%'
     * </code>
     *
     * @param     string $lastname The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return JasminumCalendarReservationsQuery The current query, for fluid interface
     */
    public function filterByLastname($lastname = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($lastname)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $lastname)) {
                $lastname = str_replace('*', '%', $lastname);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(JasminumCalendarReservationsPeer::LASTNAME, $lastname, $comparison);
    }

    /**
     * Filter the query on the Email column
     *
     * Example usage:
     * <code>
     * $query->filterByEmail('fooValue');   // WHERE Email = 'fooValue'
     * $query->filterByEmail('%fooValue%'); // WHERE Email LIKE '%fooValue%'
     * </code>
     *
     * @param     string $email The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return JasminumCalendarReservationsQuery The current query, for fluid interface
     */
    public function filterByEmail($email = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($email)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $email)) {
                $email = str_replace('*', '%', $email);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(JasminumCalendarReservationsPeer::EMAIL, $email, $comparison);
    }

    /**
     * Filter the query on the Date_From column
     *
     * Example usage:
     * <code>
     * $query->filterByDateFrom('2011-03-14'); // WHERE Date_From = '2011-03-14'
     * $query->filterByDateFrom('now'); // WHERE Date_From = '2011-03-14'
     * $query->filterByDateFrom(array('max' => 'yesterday')); // WHERE Date_From > '2011-03-13'
     * </code>
     *
     * @param     mixed $dateFrom The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return JasminumCalendarReservationsQuery The current query, for fluid interface
     */
    public function filterByDateFrom($dateFrom = null, $comparison = null)
    {
        if (is_array($dateFrom)) {
            $useMinMax = false;
            if (isset($dateFrom['min'])) {
                $this->addUsingAlias(JasminumCalendarReservationsPeer::DATE_FROM, $dateFrom['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($dateFrom['max'])) {
                $this->addUsingAlias(JasminumCalendarReservationsPeer::DATE_FROM, $dateFrom['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(JasminumCalendarReservationsPeer::DATE_FROM, $dateFrom, $comparison);
    }

    /**
     * Filter the query on the Date_To column
     *
     * Example usage:
     * <code>
     * $query->filterByDateTo('2011-03-14'); // WHERE Date_To = '2011-03-14'
     * $query->filterByDateTo('now'); // WHERE Date_To = '2011-03-14'
     * $query->filterByDateTo(array('max' => 'yesterday')); // WHERE Date_To > '2011-03-13'
     * </code>
     *
     * @param     mixed $dateTo The value to use as filter.
     *              Values can be integers (unix timestamps), DateTime objects, or strings.
     *              Empty strings are treated as NULL.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return JasminumCalendarReservationsQuery The current query, for fluid interface
     */
    public function filterByDateTo($dateTo = null, $comparison = null)
    {
        if (is_array($dateTo)) {
            $useMinMax = false;
            if (isset($dateTo['min'])) {
                $this->addUsingAlias(JasminumCalendarReservationsPeer::DATE_TO, $dateTo['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($dateTo['max'])) {
                $this->addUsingAlias(JasminumCalendarReservationsPeer::DATE_TO, $dateTo['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(JasminumCalendarReservationsPeer::DATE_TO, $dateTo, $comparison);
    }

    /**
     * Filter the query on the Phone column
     *
     * Example usage:
     * <code>
     * $query->filterByPhone('fooValue');   // WHERE Phone = 'fooValue'
     * $query->filterByPhone('%fooValue%'); // WHERE Phone LIKE '%fooValue%'
     * </code>
     *
     * @param     string $phone The value to use as filter.
     *              Accepts wildcards (* and % trigger a LIKE)
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return JasminumCalendarReservationsQuery The current query, for fluid interface
     */
    public function filterByPhone($phone = null, $comparison = null)
    {
        if (null === $comparison) {
            if (is_array($phone)) {
                $comparison = Criteria::IN;
            } elseif (preg_match('/[\%\*]/', $phone)) {
                $phone = str_replace('*', '%', $phone);
                $comparison = Criteria::LIKE;
            }
        }

        return $this->addUsingAlias(JasminumCalendarReservationsPeer::PHONE, $phone, $comparison);
    }

    /**
     * Filter the query on the Hall column
     *
     * Example usage:
     * <code>
     * $query->filterByHall(1234); // WHERE Hall = 1234
     * $query->filterByHall(array(12, 34)); // WHERE Hall IN (12, 34)
     * $query->filterByHall(array('min' => 12)); // WHERE Hall >= 12
     * $query->filterByHall(array('max' => 12)); // WHERE Hall <= 12
     * </code>
     *
     * @param     mixed $hall The value to use as filter.
     *              Use scalar values for equality.
     *              Use array values for in_array() equivalent.
     *              Use associative array('min' => $minValue, 'max' => $maxValue) for intervals.
     * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
     *
     * @return JasminumCalendarReservationsQuery The current query, for fluid interface
     */
    public function filterByHall($hall = null, $comparison = null)
    {
        if (is_array($hall)) {
            $useMinMax = false;
            if (isset($hall['min'])) {
                $this->addUsingAlias(JasminumCalendarReservationsPeer::HALL, $hall['min'], Criteria::GREATER_EQUAL);
                $useMinMax = true;
            }
            if (isset($hall['max'])) {
                $this->addUsingAlias(JasminumCalendarReservationsPeer::HALL, $hall['max'], Criteria::LESS_EQUAL);
                $useMinMax = true;
            }
            if ($useMinMax) {
                return $this;
            }
            if (null === $comparison) {
                $comparison = Criteria::IN;
            }
        }

        return $this->addUsingAlias(JasminumCalendarReservationsPeer::HALL, $hall, $comparison);
    }

    /**
     * Exclude object from result
     *
     * @param   JasminumCalendarReservations $jasminumCalendarReservations Object to remove from the list of results
     *
     * @return JasminumCalendarReservationsQuery The current query, for fluid interface
     */
    public function prune($jasminumCalendarReservations = null)
    {
        if ($jasminumCalendarReservations) {
            $this->addUsingAlias(JasminumCalendarReservationsPeer::ID, $jasminumCalendarReservations->getId(), Criteria::NOT_EQUAL);
        }

        return $this;
    }

}
